package com.project.controller;


import com.project.dto.UpdateAcceptanceItemDTO;
import com.project.vo.AcceptanceItemDetailVO;
import com.project.vo.AcceptanceItemsVO;
import com.project.vo.AcceptanceStatisticsVO;
import com.project.result.Result;
import com.project.service.AcceptanceItemService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/acceptance-items")
public class AcceptanceItemController {

    @Autowired
    private AcceptanceItemService acceptanceItemService;

    @GetMapping("/{id}")
    public Result<AcceptanceItemDetailVO> getId(@PathVariable Long id) {
        AcceptanceItemDetailVO detailVO = acceptanceItemService.getByIds( id);
        return Result.success(detailVO);
    }

    @PutMapping("/{id}")
    public Result update(@PathVariable Long id , @RequestBody UpdateAcceptanceItemDTO updateAcceptanceItemDTO  ) {

        acceptanceItemService.updated(id, updateAcceptanceItemDTO);
        return Result.success();
    }

    @GetMapping("/statistics/{acceptanceId}")
    public Result<AcceptanceStatisticsVO> getStatistics(@PathVariable Long acceptanceId) {
        AcceptanceStatisticsVO statisticsVO = acceptanceItemService.getStatistics(acceptanceId);
        return Result.success(statisticsVO);
    }
}